home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / CodeBox.as < prev    next >
Encoding:
Text File  |  2007-09-27  |  2.2 KB  |  88 lines

  1. class CodeBox
  2. {
  3.    var bInvincible;
  4.    var mcRef;
  5.    static var aRIGHT_CODES = ["PUPUNUNU"];
  6.    function CodeBox(__mcRef)
  7.    {
  8.       this.bInvincible = false;
  9.       Main.Instance.doAddListener(this);
  10.    }
  11.    function doEnterFrame()
  12.    {
  13.       if(this.mcRef._currentframe == 2)
  14.       {
  15.          if(this.mcRef.mcCodeEnterBox._currentframe == this.mcRef.mcCodeEnterBox._totalframes)
  16.          {
  17.             if(this.bInvincible)
  18.             {
  19.                this.doGoToFrame(3);
  20.             }
  21.             else
  22.             {
  23.                this.doGoToFrame(1);
  24.             }
  25.          }
  26.       }
  27.    }
  28.    function setBox(_mcRef)
  29.    {
  30.       this.mcRef = _mcRef;
  31.       if(!this.bInvincible)
  32.       {
  33.          this.doGoToFrame(1);
  34.       }
  35.       else
  36.       {
  37.          this.doGoToFrame(3);
  38.       }
  39.    }
  40.    function onExitBox()
  41.    {
  42.       this.mcRef.mcCodeEnterBox.play();
  43.    }
  44.    function onTurnOffClick()
  45.    {
  46.       this.bInvincible = false;
  47.       this.doGoToFrame(1);
  48.    }
  49.    function doConfirmCode()
  50.    {
  51.       var _loc2_ = this.mcRef.mcCodeEnterBox.mcField.txtCode.text;
  52.       this.bInvincible = Library.Utils.Tools.isItemInArray(CodeBox.aRIGHT_CODES,_loc2_.toUpperCase());
  53.       if(this.bInvincible)
  54.       {
  55.          this.mcRef.mcCodeEnterBox.play();
  56.       }
  57.       else
  58.       {
  59.          this.mcRef.mcCodeEnterBox.mcInvalid._visible = true;
  60.       }
  61.    }
  62.    function onEnterCodeClick()
  63.    {
  64.       this.doGoToFrame(2);
  65.    }
  66.    function get Invincible()
  67.    {
  68.       return this.bInvincible;
  69.    }
  70.    function doGoToFrame(_nFrame)
  71.    {
  72.       this.mcRef.gotoAndStop(_nFrame);
  73.       switch(_nFrame)
  74.       {
  75.          case 1:
  76.             this.mcRef.btnEnter.onRelease = Library.Utils.Delegate.create(this,this.onEnterCodeClick);
  77.             break;
  78.          case 2:
  79.             this.mcRef.mcCodeEnterBox.btnConfirm.onRelease = Library.Utils.Delegate.create(this,this.doConfirmCode);
  80.             this.mcRef.mcCodeEnterBox.btnExit.onRelease = Library.Utils.Delegate.create(this,this.onExitBox);
  81.             this.mcRef.mcCodeEnterBox.mcInvalid._visible = false;
  82.             break;
  83.          case 3:
  84.             this.mcRef.btnOff.onRelease = Library.Utils.Delegate.create(this,this.onTurnOffClick);
  85.       }
  86.    }
  87. }
  88.